<?php

namespace yiike\store\model;

use Yii;
use \yiike\store\model\base\TtycCategory as BaseTtycCategory;
use yii\helpers\ArrayHelper;
use trntv\filekit\behaviors\UploadBehavior;
/**
 * This is the model class for table "ims_ttyc_category".
 */
class TtycCategory extends BaseTtycCategory
{
    public $logo_file;

    public function behaviors()
    {
        return ArrayHelper::merge(
            parent::behaviors(),
            [
                [
                    'class' => UploadBehavior::className(),
                    'attribute' => 'logo_file',
                    'pathAttribute' => 'logo',
                ],
            ]
        );
    }

    public function rules()
    {
        return ArrayHelper::merge(
            parent::rules(),
            [
                # custom validation rules
            ]
        );
    }
    public function beforeSave($insert)
    {

        $this->logo = $_POST['TtycCategory']['logo_file']['path'];
        return parent::beforeSave($insert); // TODO: Change the autogenerated stub
    }
    function afterFind()
    {

        $this->logo_file = Yii::getAlias('@storageUrl/source').'/'.$this->logo ;
        parent::afterFind(); // TODO: Change the autogenerated stub
    }

}
